<div id="payment">
    <div class="heading">
        <a href="#"><img src="resource/images/img-17-8.jpg" /></a>
        为朋友代付
    </div>
    <p>亲，商品仍需支付<span>￥<?php echo $output['order_info']['bg_order_price'];?></span> 动动手指头，让你们的友情散发无敌的光芒</p>
    <div class="option">
        <span>选择金额</span>

        <?php if($output['friends_pay']['0'] !==''){ ?>

            <div class="line" style="white-space:normal;">
            <?php foreach($output['friends_pay'] as $k =>$v ) {?>
               <span><img src="resource/images/img-17-4.png" /><?php echo $v; ?></span>
            <?php  }?>
              </div>


        <?php }else{?>
        <div class="line">
            <span><img src="resource/images/img-17-4.png" />0.68</span>
            <span><img src="resource/images/img-17-4.png"  />1.28</span>
            <span><img src="resource/images/img-17-4.png"  />5.20</span>
        </div>
        <div class="line">
            <span><img src="resource/images/img-17-4.png"  />0.68</span>
            <span><img src="resource/images/img-17-4.png" />1.28</span>
            <span><img src="resource/images/img-17-4.png" />5.20</span>
        </div>
        <div class="line">
            <span><img src="resource/images/img-17-4.png" />0.68</span>
            <span><img src="resource/images/img-17-4.png" />1.28</span>
            <span><img src="resource/images/img-17-4.png" />5.20</span>
        </div>
        <div class="line">
            <span><img src="resource/images/img-17-4.png" />0.68</span>
            <span><img src="resource/images/img-17-4.png" />1.28</span>
            <span><img src="resource/images/img-17-4.png" />5.20</span>
        </div>
        <?php } ?>
        <form id="payment_form" onsubmit="return false;">
            付款金额
            <input type="text" name="price"  onkeyup="value=value.replace(/[^\d\.]/g,'')" placeholder="请输入金额" />
            <input type="hidden" name="price2" value="">
            <input type="hidden" name="form_submit" value="ok">
            <a href="javascript:;" class="submit">提交</a>
        </form>

    </div>
</div>
<script>
    $(".line span").click(function(){
        $("[name='price2']").val($(this).text());
        $("[name='price']").val('');
    });
    $("[name='price']").change(function(){
        $("[name='price2']").val();
    })
    $(".submit").click(function(){
        var is_weixin = '<?php echo $output['is_weixin'] ?>' ;
        var price2 = $("[name='price2']").val();
        var price  = $("[name='price']").val();
        if(price2=='' && price==''){
            popAlert('代付金额不能为空哦！');
            return;
        }


        var pay_price = '';
        (price !== '') ? pay_price = price : pay_price=price2;
        if(pay_price><?php echo $output['order_info']['bg_order_price'];?>){
            popAlert('代付金额不能超过实际价格噢！');
            return;
        }
        $.post(location.href,$("#payment_form").serialize(),function(result){
              try {
                popAlert(result.datas.error);
            }catch (e){
                if(is_weixin ==''){
                   window.location.href = result.data.code_url;
                }else{
                    $('html').append(result.data.html);
                }
            }


        },'json');
    })
</script>